<template>
  <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="数据已经见底了"
      @load="onLoad"
    >
      <slot></slot>
    </van-list>
  </van-pull-refresh>
</template>


<script>
export default {
  name: "loadmore",
  props: {
    getmovielist: Function,
    movielistadd: Function,
  },
  data() {
    return {
      isLoading: false,
      loading: false,
      finished: false, //数据见底了
    };
  },
  methods: {
    // 加载更多
    onLoad() {
      setTimeout(() => {
        // this.loading = false;
        this.movielistadd(
          () => {
            this.finished = true;
            this.$toast("数据见底了");
          },
          () => {
            this.loading = false;
            this.$toast("数据见底了");
          }
        );
      }, 1000);
    },

    // 下拉刷新
    onRefresh() {
      this.getmovielist();
      setTimeout(() => {
        this.$toast("刷新成功");
        this.isLoading = false; //下拉刷新结束
      }, 1000);
    },
  },
};
</script>